\documentclass{article}

\begin{document}
\SweaveOpts{concordance=TRUE}

<<>>=
library(ggeffects)
library(lme4)
@

<<Figure 1>>=
ce <- c(-0.25, 0.55, 0.13, -0.09, 0.05, 0.18, 0.08)         # coefficients b1, b2
ic <- c(-1.65, 0.37, 3.58)                # intercepts b0.1, b0.2, b0.3
X1 <- 1 #never vote a party
X2 <- 1 #vote winner
X3 <- X1*X2 #int never vote and winner
X4 <- 0 #non-voter
X5 <- X1*X4 #int never vote and non-voter
X6 <- 1 #political interest
X7 <- 1 #income quintile
#PPID, female, scaled GDP, scaled age, scaled education, ideological distance treated as zero

logit1 <- ic[1] - (ce[1]*X1 + ce[2]*X2 + ce[3]*X3 + ce[4]*X4 + ce[5]*X5 + ce[6]*X7 + ce[7]*X7)
logit2 <- ic[2] - (ce[1]*X1 + ce[2]*X2 + ce[3]*X3 + ce[4]*X4 + ce[5]*X5 + ce[6]*X7 + ce[7]*X7)
logit3 <- ic[3] - (ce[1]*X1 + ce[2]*X2 + ce[3]*X3 + ce[4]*X4 + ce[5]*X5 + ce[6]*X7 + ce[7]*X7)
pLeq1  <- 1 / (1 + exp(-logit1))   # p(Y <= 1)
pLeq2  <- 1 / (1 + exp(-logit2))   # p(Y <= 2)
pLeq3  <- 1 / (1 + exp(-logit3))   # p(Y <= 3)
pMat   <- cbind(p1=pLeq1, p2=pLeq2-pLeq1, p3=pLeq3-pLeq2, p4=1-pLeq3)  # matrix p(Y = g)
pMat

par(family='serif')
plot(x=1, xlim=c(-1.5,1.5), ylim=c(0,.6), type="n", xaxt='n', ylab="Probability of Level of Satisfaction")
legend(-1.5,.62, legend=c("Very", "Fairly", "Not Very", "Not at All"), pch=c(1,2,0,5), cex=01, bty="n",y.intersp=.4)
legend(-1.58,.545, legend=c("NPID", "No NPID"), col=c("grey", "black"), lty=1, cex=01, bty="n",y.intersp=.4, seg.len=.9,  x.intersp=.6)

# Yes Neg, NV, L , W
pvsY <- c(0.02633932, 0.02738481, 0.05265012)
pfsY <- c(0.374973, 0.3835748, 0.5266741)
pnvsY <- c(0.4334828, 0.4292784, 0.3328118)
pnasY <- c(0.1652049, 0.159762, 0.08786391)

#very
points(x=-1, y=0.02633932, pch=1, col="grey")
points(x=0, y=0.02738481, pch=1, col="grey")
points(x=1, y=0.05265012, pch=1, col="grey")
segments(x0=-1, 0.02633932, x1 = 0, y1 = 0.02738481, col="grey")
segments(x0=0, 0.02738481, x1 = 1, y1 = 0.05265012, col="grey")

#fairly
points(x=-1, y=0.374973, pch=2, col="grey")
points(x=0, y=0.3835748, pch=2, col="grey")
points(x=1, y=0.5266741, pch=2, col="grey")
segments(x0=-1, 0.374973, x1 = 0, y1 = 0.3835748, col="grey")
segments(x0=0, 0.3835748, x1 = 1, y1 = 0.5266741, col="grey")

#not very
points(x=-1, y=0.4334828, pch=0, col="grey")
points(x=0, y=0.4292784, pch=0, col="grey")
points(x=1, y=0.3328118, pch=0, col="grey")
segments(x0=-1, 0.4334828, x1 = 0, y1 = 0.4292784, col="grey")
segments(x0=0, 0.4292784, x1 = 1, y1 = 0.3328118, col="grey")

#not at all
points(x=-1, y=0.1652049, pch=5, col="grey")
points(x=0, y=0.159762, pch=5, col="grey")
points(x=1, y=0.08786391, pch=5, col="grey")
segments(x0=-1, 0.1652049, x1 = 0, y1 = 0.159762, col="grey")
segments(x0=0, 0.159762, x1 = 1, y1 = 0.08786391, col="grey")


# No Neg, NV, L , W
pvsN <- c(0.0319844, 0.03489141, 0.05896701)
pfsN <- c(0.4181816, 0.4376363, 0.549292)
pnvsN <- c(0.4104001, 0.3984915, 0.3130306)
pnasN <- c(0.1394339, 0.1289809, 0.07871034)

#very
points(x=-1, y=0.0319844, pch=1)
points(x=0, y=0.03489141, pch=1)
points(x=1, y=0.05896701, pch=1)
segments(x0=-1, 0.0319844, x1 = 0, y1 = 0.03489141)
segments(x0=0, 0.03489141, x1 = 1, y1 = 0.05896701)

#fairly
points(x=-1, y=0.4181816, pch=2)
points(x=0, y=0.4376363, pch=2)
points(x=1, y=0.549292, pch=2)
segments(x0=-1, 0.4181816, x1 = 0, y1 = 0.4376363)
segments(x0=0, 0.4376363, x1 = 1, y1 = 0.549292)

#not very
points(x=-1, y=0.4104001, pch=0)
points(x=0, y=0.3984915, pch=0)
points(x=1, y=0.3130306, pch=0)
segments(x0=-1, 0.4104001, x1 = 0, y1 = 0.3984915)
segments(x0=0, 0.3984915, x1 = 1, y1 = 0.3130306)

#not at all
points(x=-1, y=0.1394339, pch=5)
points(x=0, y=0.1289809, pch=5)
points(x=1, y=0.07871034, pch=5)
segments(x0=-1, 0.1394339, x1 = 0, y1 = 0.1289809)
segments(x0=0, 0.1289809, x1 = 1, y1 = 0.07871034)
@

<<Figure 2>>=
ce <- c(0.12, -0.51, 0.04, -0.69, 0.05, 0.19, 0.07)         # coefficients b1, b2,...
ic <- c(-1.41, 0.68, 3.95)                # intercepts b0.1, b0.2, b0.3
X1 <- 8 #like the governing party
X2 <- 1 #vote losing party
X3 <- X1*X2 #int never vote and winner
X4 <- 0 #non-voter
X5 <- X1*X4 #int never vote and non-voter
X6 <- 1 #political interest
X7 <- 1 #income quintile
#PPID, female, scaled GDP, scaled age, scaled education, ideological distance treated as zero

logit1 <- ic[1] - (ce[1]*X1 + ce[2]*X2 + ce[3]*X3 + ce[4]*X4 + ce[5]*X5 + ce[6]*X7 + ce[7]*X7)
logit2 <- ic[2] - (ce[1]*X1 + ce[2]*X2 + ce[3]*X3 + ce[4]*X4 + ce[5]*X5 + ce[6]*X7 + ce[7]*X7)
logit3 <- ic[3] - (ce[1]*X1 + ce[2]*X2 + ce[3]*X3 + ce[4]*X4 + ce[5]*X5 + ce[6]*X7 + ce[7]*X7)
pLeq1  <- 1 / (1 + exp(-logit1))   # p(Y <= 1)
pLeq2  <- 1 / (1 + exp(-logit2))   # p(Y <= 2)
pLeq3  <- 1 / (1 + exp(-logit3))   # p(Y <= 3)
pMat   <- cbind(p1=pLeq1, p2=pLeq2-pLeq1, p3=pLeq3-pLeq2, p4=1-pLeq3)  # matrix p(Y = g)
pMat

par(family='serif')
plot(x=1, xlim=c(-1.5,1.5), ylim=c(0,.7), type="n", xaxt='n', ylab="Probability of Level of Satisfaction")
legend(-1.5,.74, legend=c("Very", "Fairly", "Not Very", "Not at All"), pch=c(1,2,0,5), cex=1, bty="n",y.intersp=.4)
legend(-1.57,.665, legend=c("Like - 8", "Like - 5", "Like - 2"), col=c("grey", "black", "grey50"), lty=1, cex=1, bty="n",y.intersp=.4, seg.len=.9,  x.intersp=.54)

# Like at 8
pvsY <- c(0.04653047, 0.0511737, 0.06122616)
pfsY <- c(0.515646, 0.5354439, 0.5705863)
pnvsY <- c(0.3499596, 0.3332095, 0.3009551)
pnasY <- c(0.08786391, 0.08017291, 0.06723245)

#very
points(x=-1, y=0.04653047, pch=1, col="grey")
points(x=0, y=0.0511737, pch=1, col="grey")
points(x=1, y=0.06122616, pch=1, col="grey")
segments(x0=-1, 0.04653047, x1 = 0, y1 = 0.0511737, col="grey")
segments(x0=0, 0.0511737, x1 = 1, y1 = 0.06122616, col="grey")

#fairly
points(x=-1, y=0.515646, pch=2, col="grey")
points(x=0, y=0.5354439, pch=2, col="grey")
points(x=1, y=0.5705863, pch=2, col="grey")
segments(x0=-1, 0.515646, x1 = 0, y1 = 0.5354439, col="grey")
segments(x0=0, 0.5354439, x1 = 1, y1 = 0.5705863, col="grey")

#not very
points(x=-1, y=0.3499596, pch=0, col="grey")
points(x=0, y=0.3332095, pch=0, col="grey")
points(x=1, y=0.3009551, pch=0, col="grey")
segments(x0=-1, 0.3499596, x1 = 0, y1 = 0.3332095, col="grey")
segments(x0=0, 0.3332095, x1 = 1, y1 = 0.3009551, col="grey")

#not at all
points(x=-1, y=0.08786391, pch=5, col="grey")
points(x=0, y=0.08017291, pch=5, col="grey")
points(x=1, y=0.06723245, pch=5, col="grey")
segments(x0=-1, 0.08786391, x1 = 0, y1 = 0.08017291, col="grey")
segments(x0=0, 0.08017291, x1 = 1, y1 = 0.06723245, col="grey")

# Like at 5
pvsN <- c(0.02847059, 0.03229546, 0.04352163)
pfsN <- c(0.4068931, 0.4352502, 0.5013573)
pnvsN <- c(0.426398, 0.4089873, 0.3614829)
pnasN <- c(0.1382383, 0.123467, 0.09363821)

#very
points(x=-1, y=0.02847059, pch=1)
points(x=0, y=0.03229546, pch=1)
points(x=1, y=0.04352163, pch=1)
segments(x0=-1, 0.02847059, x1 = 0, y1 = 0.03229546)
segments(x0=0, 0.03229546, x1 = 1, y1 = 0.04352163)

#fairly
points(x=-1, y=0.4068931, pch=2)
points(x=0, y=0.4352502, pch=2)
points(x=1, y=0.5013573, pch=2)
segments(x0=-1, 0.4068931, x1 = 0, y1 = 0.4352502)
segments(x0=0, 0.4352502, x1 = 1, y1 = 0.5013573)

#not very
points(x=-1, y=0.426398, pch=0)
points(x=0, y=0.4089873, pch=0)
points(x=1, y=0.3614829, pch=0)
segments(x0=-1, 0.426398, x1 = 0, y1 = 0.4089873)
segments(x0=0, 0.4089873, x1 = 1, y1 = 0.3614829)

#not at all
points(x=-1, y=0.1382383, pch=5)
points(x=0, y=0.123467, pch=5)
points(x=1, y=0.09363821, pch=5)
segments(x0=-1, 0.1382383, x1 = 0, y1 = 0.123467)
segments(x0=0, 0.123467, x1 = 1, y1 = 0.09363821)

# Like at 2
pvsN <- c(0.01729316, 0.020233, 0.03076886)
pfsN <- c(0.2991859, 0.3318262, 0.4243522)
pnvsN <- c(0.4727026, 0.4625134, 0.415898)
pnasN <- c(0.2108183, 0.1854274, 0.1289809)

#very
points(x=-1, y=0.01729316, pch=1, col="grey50")
points(x=0, y=0.020233, pch=1, col="grey50")
points(x=1, y=0.03076886, pch=1, col="grey50")
segments(x0=-1, 0.01729316, x1 = 0, y1 = 0.020233, col="grey50")
segments(x0=0, 0.020233, x1 = 1, y1 = 0.03076886, col="grey50")

#fairly
points(x=-1, y=0.2991859, pch=2, col="grey50")
points(x=0, y=0.3318262, pch=2, col="grey50")
points(x=1, y=0.4243522, pch=2, col="grey50")
segments(x0=-1, 0.2991859, x1 = 0, y1 = 0.3318262, col="grey50")
segments(x0=0, 0.3318262, x1 = 1, y1 = 0.4243522, col="grey50")

#not very
points(x=-1, y=0.4727026, pch=0, col="grey50")
points(x=0, y=0.4625134, pch=0, col="grey50")
points(x=1, y=0.415898, pch=0, col="grey50")
segments(x0=-1, 0.4727026, x1 = 0, y1 = 0.4625134, col="grey50")
segments(x0=0, 0.4625134, x1 = 1, y1 = 0.415898, col="grey50")

#not at all
points(x=-1, y=0.2108183, pch=5, col="grey50")
points(x=0, y=0.1854274, pch=5, col="grey50")
points(x=1, y=0.1289809, pch=5, col="grey50")
segments(x0=-1, 0.2108183, x1 = 0, y1 = 0.1854274, col="grey50")
segments(x0=0, 0.1854274, x1 = 1, y1 = 0.1289809, col="grey50")
@

<<Figure 3>>=
ce <- c(0.19, 0.50, -0.05, -0.18, -0.00, 0.14, 0.08)         # coefficients b1, b2
ic <- c(-1.06, 1.04, 4.55)                # intercepts b0.1, b0.2, b0.3
X1 <- 2 #like the governing party
X2 <- 1 #vote winning party
X3 <- X1*X2 #int never vote and winner
X4 <- 0 #non-votehr
X5 <- X1*X4 #int never vote and non-voter
X6 <- 1 #political interest
X7 <- 1 #income quintile
#PPID, female, scaled GDP, scaled age, scaled education, ideological distance treated as zero

logit1 <- ic[1] - (ce[1]*X1 + ce[2]*X2 + ce[3]*X3 + ce[4]*X4 + ce[5]*X5 + ce[6]*X7 + ce[7]*X7)
logit2 <- ic[2] - (ce[1]*X1 + ce[2]*X2 + ce[3]*X3 + ce[4]*X4 + ce[5]*X5 + ce[6]*X7 + ce[7]*X7)
logit3 <- ic[3] - (ce[1]*X1 + ce[2]*X2 + ce[3]*X3 + ce[4]*X4 + ce[5]*X5 + ce[6]*X7 + ce[7]*X7)
pLeq1  <- 1 / (1 + exp(-logit1))   # p(Y <= 1)
pLeq2  <- 1 / (1 + exp(-logit2))   # p(Y <= 2)
pLeq3  <- 1 / (1 + exp(-logit3))   # p(Y <= 3)
pMat   <- cbind(p1=pLeq1, p2=pLeq2-pLeq1, p3=pLeq3-pLeq2, p4=1-pLeq3)  # matrix p(Y = g)
pMat

par(family='serif')
plot(x=1, xlim=c(-1.5,1.5), ylim=c(0,.7), type="n", xaxt='n', ylab="Probability of Level of Satisfaction")
legend(-1.5,.74, legend=c("Very", "Fairly", "Not Very", "Not at All"), pch=c(1,2,0,5), cex=1, bty="n",y.intersp=.4)
legend(-1.57,.665, legend=c("Like - 8", "Like - 5", "Like - 2"), col=c("grey", "black", "grey50"), lty=1, cex=1, bty="n",y.intersp=.4, seg.len=.9,  x.intersp=.54)

# Like at 8
pvsY <- c(0.04787969, 0.05678618, 0.06238585)
pfsY <- c(0.5792681, 0.6114016, 0.6275886)
pnvsY <- c(0.3049899, 0.2744881, 0.257872)
pnasY <- c(0.06786229, 0.05732418, 0.05215356)

#very
points(x=-1, y=0.04787969, pch=1, col="grey")
points(x=0, y=0.05678618, pch=1, col="grey")
points(x=1, y=0.06238585, pch=1, col="grey")
segments(x0=-1, 0.04787969, x1 = 0, y1 = 0.05678618, col="grey")
segments(x0=0, 0.05678618, x1 = 1, y1 = 0.06238585, col="grey")

#fairly
points(x=-1, y=0.5792681, pch=2, col="grey")
points(x=0, y=0.6114016, pch=2, col="grey")
points(x=1, y=0.6275886, pch=2, col="grey")
segments(x0=-1, 0.5792681, x1 = 0, y1 = 0.6114016, col="grey")
segments(x0=0, 0.6114016, x1 = 1, y1 = 0.6275886, col="grey")

#not very
points(x=-1, y=0.3049899, pch=0, col="grey")
points(x=0, y=0.2744881, pch=0, col="grey")
points(x=1, y=0.257872, pch=0, col="grey")
segments(x0=-1, 0.3049899, x1 = 0, y1 = 0.2744881, col="grey")
segments(x0=0, 0.2744881, x1 = 1, y1 = 0.257872, col="grey")

#not at all
points(x=-1, y=0.06786229, pch=5, col="grey")
points(x=0, y=0.05732418, pch=5, col="grey")
points(x=1, y=0.05215356, pch=5, col="grey")
segments(x0=-1, 0.06786229, x1 = 0, y1 = 0.05732418, col="grey")
segments(x0=0, 0.05732418, x1 = 1, y1 = 0.05215356, col="grey")

# Like at 5
pvsN <- c(0.02765242, 0.03292639, 0.04188661)
pfsN <- c(0.4598502, 0.4995279, 0.5519865)
pnvsN <- c(0.398445, 0.3704571, 0.3288547)
pnasN <- c(0.1140524, 0.09708864, 0.0772722)

#very
points(x=-1, y=0.02765242, pch=1)
points(x=0, y=0.03292639, pch=1)
points(x=1, y=0.04188661, pch=1)
segments(x0=-1, 0.02765242, x1 = 0, y1 = 0.03292639)
segments(x0=0, 0.03292639, x1 = 1, y1 = 0.04188661)

#fairly
points(x=-1, y=0.4598502, pch=2)
points(x=0, y=0.4995279, pch=2)
points(x=1, y=0.5519865, pch=2)
segments(x0=-1, 0.4598502, x1 = 0, y1 = 0.4995279)
segments(x0=0, 0.4995279, x1 = 1, y1 = 0.5519865)

#not very
points(x=-1, y=0.398445, pch=0)
points(x=0, y=0.3704571, pch=0)
points(x=1, y=0.3288547, pch=0)
segments(x0=-1, 0.398445, x1 = 0, y1 = 0.3704571)
segments(x0=0, 0.3704571, x1 = 1, y1 = 0.3288547)

#not at all
points(x=-1, y=0.1140524, pch=5)
points(x=0, y=0.09708864, pch=5)
points(x=1, y=0.0772722, pch=5)
segments(x0=-1, 0.1140524, x1 = 0, y1 = 0.09708864)
segments(x0=0, 0.09708864, x1 = 1, y1 = 0.0772722)

# Like at 2
pvsN <- c(0.01582831, 0.01889096, 0.02792257)
pfsN <- c(0.3339531, 0.37285, 0.4620788)
pnvsN <- c(0.4647911, 0.448497, 0.3969528)
pnasN <- c(0.1854274, 0.159762, 0.1130458)

#very
points(x=-1, y=0.01582831, pch=1, col="grey50")
points(x=0, y=0.01889096, pch=1, col="grey50")
points(x=1, y=0.02792257, pch=1, col="grey50")
segments(x0=-1, 0.01582831, x1 = 0, y1 = 0.01889096, col="grey50")
segments(x0=0, 0.01889096, x1 = 1, y1 = 0.02792257, col="grey50")

#fairly
points(x=-1, y=0.3339531, pch=2, col="grey50")
points(x=0, y=0.37285, pch=2, col="grey50")
points(x=1, y=0.4620788, pch=2, col="grey50")
segments(x0=-1, 0.3339531, x1 = 0, y1 = 0.37285, col="grey50")
segments(x0=0, 0.37285, x1 = 1, y1 = 0.4620788, col="grey50")

#not very
points(x=-1, y=0.4647911, pch=0, col="grey50")
points(x=0, y=0.448497, pch=0, col="grey50")
points(x=1, y=0.3969528, pch=0, col="grey50")
segments(x0=-1, 0.4647911, x1 = 0, y1 = 0.448497, col="grey50")
segments(x0=0, 0.448497, x1 = 1, y1 = 0.3969528, col="grey50")

#not at all
points(x=-1, y=0.1854274, pch=5, col="grey50")
points(x=0, y=0.159762, pch=5, col="grey50")
points(x=1, y=0.1130458, pch=5, col="grey50")
segments(x0=-1, 0.1854274, x1 = 0, y1 = 0.159762, col="grey50")
segments(x0=0, 0.159762, x1 = 1, y1 = 0.1130458, col="grey50")
@
\end{document}
